import { StoreModel } from '../../models/storeModel.js'
let storeModel = new StoreModel()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    storeList:[],
    storeName: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.storeName)
    let reqData = { 'pageSize': '20' }
    storeModel.getStoreList(reqData)
    .then(res=>{
      this.setData({
        storeList: res.object.result,
        storeName: options.storeName
      })
    })
  },
  storeChoose(e){
    console.log(e.currentTarget.dataset.storename)
    this.setData({
      storeName: e.currentTarget.dataset.storename
    })
    wx.reLaunch({
      url: `../index/index?storeName=${e.currentTarget.dataset.storename}`
    })
  }
})